package org.boot.ssm.wxshop.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.boot.ssm.wxshop.common.impl.BaseServiceImpl;
import org.boot.ssm.wxshop.domain.GoodsTypeSmall;
import org.boot.ssm.wxshop.mapper.GoodsTypeSmallMapper;
import org.boot.ssm.wxshop.service.GoodsTypeSmallService;
import org.boot.ssm.wxshop.util.WebConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: wxshop
 * @description: GoodsTypeSmallService的实现类
 * @author: Parasomnia
 * @create: 2018-03-13 22:03
 **/
@Service
public class GoodsTypeSmallServiceImpl extends BaseServiceImpl<GoodsTypeSmall> implements GoodsTypeSmallService{

    @Autowired
    private GoodsTypeSmallMapper goodsTypeSmallMapper;


    @Override
    public PageInfo<GoodsTypeSmall> queryPageListByName(Integer pageNum,Integer pageSize,GoodsTypeSmall goodsTypeSmall) {
        PageHelper.startPage(pageNum, pageSize);
        List<GoodsTypeSmall> list=goodsTypeSmallMapper.selectAllPlus(goodsTypeSmall);
        // 用PageInfo对结果进行包装
        PageInfo<GoodsTypeSmall> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    @Transactional
    public void addOrEditType(GoodsTypeSmall goodsTypeSmall) {
        if(goodsTypeSmall.getId()==null){//添加
            saveNoNull(goodsTypeSmall);
        }else {//修改
            updateNoNull(goodsTypeSmall);
        }
    }
}
